<template>
<view>
	<view class="avatar">
	    <image class="heading_img" :src="avatar"></image>
	</view>
	
	<image class="rcode" v-if="codeUrl" :src="imgUrl+codeUrl"></image>
	
	<button @click="share" class="myshare">分享</button>
	<!-- <view class="share">
		 <image v-if="codeUrl" :src="imgUrl+codeUrl"></image>
		 <button @click="share" class="myshare">分享</button>
	</view> -->
</view>
</template>
<script>
import request from '@/util/request.js'
export default {
	data() {
		return{
			avatar:wx.getStorageSync('avatarUrl'),
			imgUrl:this.url,
			codeUrl:''
		}
	},
	onLoad:function(){
		this.getRcode();
	},
	methods: {
		getRcode:function(){
			var that = this
			var data = {'uid':uni.getStorageSync('uid')}
			request({
				url: 'member/rcode',
				method: 'get',
				data:data,
				success: (res) => {
					that.codeUrl = res.data.data
				}
			})
		},
		share:function(){
			var img = this.imgUrl + this.codeUrl
			uni.share({
			    provider: "weixin",
			    scene: "WXSceneSession",
			    type: 5,
			    imageUrl:img,
			    title: '天意美业直通车',
				miniProgram: {
					id: 'gh_42fb5eed1670',
					path: 'pages/index/index',
					type: 0,
					webUrl: 'https://www.tymyztc.com'
				},
				success: ret => {
					console.log(JSON.stringify(ret));
				}
			});
		}
	}
}
</script>
<style>
.avatar{
	background: #ff861a;
	width:100%;
	height:100px;
	display: flex;
	justify-content:center;
}
.heading_img{
	width:80px;
	height:80px;
	border-radius: 50%;
	margin-top:10px;
}
.rcode{
	width:100%;
	height:750rpx;
}

.myshare{
	height:80rpx;
	line-height:80rpx;
	margin-top:20px;
	width:450rpx;
	background:#ff861a;
	color:#FFFFFF;
}
</style>